//用于判断按钮开关状态
let myToggleStatus;

let toggleEl = null
// let toggleEl = document.querySelector('.toggle')

let returnBtn = document.querySelector('#return')

let toggleElList = document.querySelectorAll('.toggle');

//初始化将每个按钮都默认设置为关闭状态
toggleElList.forEach(el => {
    el.dataset.flag = false
});

returnBtn.addEventListener('click', returnPage)

function returnPage(){
    location.href = '././userMmt.html'
}
//判断是否点击的是按钮
document.addEventListener('click', function (e) {

    if(e.target.matches('.toggle')) {
        // debugger
        toggleEl = e.target
        if (toggleEl.classList.contains('close')) myToggleStatus = false
        else myToggleStatus = true

        handleToggle()
    }
  })


function handleToggle() {
    myToggleStatus = !myToggleStatus
    changeToggleStyle()
}

//进行按钮开关切换
function changeToggleStyle() {
    if (myToggleStatus) {
        toggleEl.style.backgroundColor = '#bedcf5';
        toggleEl.classList.add('toggle_on');
        toggleEl.classList.remove('close')
        toggleEl.classList.add('open');
        
    } else {
        toggleEl.style.backgroundColor = '#cecaca';
        toggleEl.classList.remove('toggle_on');
        toggleEl.classList.remove('open')
        toggleEl.classList.add('close');
    }
}